// TOWN SCRIPT
//    Town 14: Westfen

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
// This state called whenever this town is entered.
		set_state_continue(11);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate 10;
	if (get_flag(14,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"The fen exhales with an an overwhelming stench. A fog rises up from the swamplands, but it's not the main reason you can't see well enough ahead. Your heads are sent spinning by the foul smell.",0);
	add_dialog_str(1,"Vaguely, you can make out the movement of inhabitants. From here, you can't tell whether they're humanoid or not, and with the sloshing of the mud and the screeching of insects you can't hear whether their mutterings are mixed in with the cacophany.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(14,0,250);
break;

beginstate 11;
	if (character_in_party(1702) >= 0) 
		set_state_continue(12);
	set_state_continue(10);
break;

beginstate 12;
	if (get_flag(14,1) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"Fernow glances around nervously. _Is he here?_ she wonders aloud. _The rumors say so, but I don't know. Maybe he's on one of the eastern islands._",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(14,1,250);
	set_state_continue(10);
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0,"The swamp sinks here into a tunnel of muck: hopeless to enter for you - the smell of the place is enough to discourage you - but doubtlessly used as a lair by the swamp monsters.",0);
	add_dialog_str(1,"Beside it, cast against a tree, the glint of dull metal catches your eye. Intrigued, you plow about a bit in the mud, and unearth a small collection of coins. They're probably not worth much.",0);
	add_dialog_str(2,"The prospect of digging them up from this place isn't very exciting. Why they would be here at all, though, is a mystery.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_state_continue(14);
break;

beginstate 14;
	if (character_in_party(1702) >= 0) 
		set_state_continue(15);
break;

beginstate 15;
	if (get_flag(14,2) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"_These are the currency of our clan,_ Fernow says, peering curiously. _I guess the rumors are true. It might have been a toll, or something, that let him pass through the tunnel._",0);
	add_dialog_str(1,"She grimaces. _Not that I want to go down there. It goes somewhere else, I'm sure._",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(14,2,250);
	set_terrain(21,21,0);
break;

beginstate 16;
	if (get_flag(111,22) >= 1)
		set_state_continue(17);
	set_state_continue(18);
break;

beginstate 17;
	message_dialog("The herb patch hasn't grown back yet.","");
break;

beginstate 18;
	reset_dialog_preset_options(1);
	add_dialog_str(0,"You find a small patch of Energetic Herbs in the swamp.",0);
	choice = run_dialog(1);
	if (choice == 2) {
		if (reward_give(216)) {
	set_flag(111,22,1);
	}
}
break;
